const commentService = require('../service/comment.service');

class CommentController {
  async create(ctx, next) {
    const {id} = ctx.user;
    const {content, momentId} = ctx.request.body;

    const result = await commentService.createComment(id, content, momentId);
    
    ctx.body = result;
  }

  async replyComment(ctx, next) {
    const {id} = ctx.user;
    const {content, momentId} = ctx.request.body;
    const {commentId} = ctx.params;

    console.log(id, content, momentId, commentId);

    const result = await commentService.replyComment(id, content, momentId, commentId);
    
    ctx.body = result;
  }

  async updatedComment(ctx, next) {
    const {commentId} = ctx.params;
    const {content} = ctx.request.body;

    const result = await commentService.updatedComment(commentId, content);
    
    ctx.body = result;
  }

  async removeComment(ctx, next) {
    const {commentId} = ctx.params;

    const result = await commentService.removeComment(commentId);
    
    ctx.body = result;
  }
}

module.exports = new CommentController();